package com.chenfei.sharding.jdbc.controller;

import com.dianping.cat.Cat;
import com.dianping.cat.message.Transaction;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenfei
 * @description
 * @since 2018/2/27
 */
@RestController
@Slf4j
public class CatController {

    @RequestMapping(value = "/test")
    public String test() throws NullPointerException{
        Transaction t = Cat.newTransaction("URL","test-page");
        try{
            log.info("begin cat");
            Cat.logEvent("URL.Server","ip");
            System.out.println("hello cat");
            log.info("end cat");
            t.setStatus(Transaction.SUCCESS);
        }catch(Exception e){
            t.setStatus(e);
        }finally {
            t.complete();
            return "success";
        }

    }
}
